package com.yyfax.pay.order.model.to;

import org.apache.commons.lang3.StringUtils;

import com.yyfax.framework.exception.YYException;
import com.yyfax.framework.yyfax.enums.RspCodeEnum;
import com.yyfax.pay.common.model.to.YYPayParams;

/**
 * 独立鉴权form请求参数
 * 
 * @author buyi
 * @date 2017-04-15 16:26:40
 * @since v1.0.0
 */
@SuppressWarnings("serial")
public class AuthCounterSignParams extends YYPayParams {
	private String userIp; // 用户端请求IP
	private String authOrderId;
	private String merchantCode; // 商户编号
	private String orderId; // 商户订单号
	private String paymentCode;
	private String idNo;
	private String name;
	private String cardNo;
	private String phone;
	/** 支付令牌 */
	private String token;
	/** 手机验证码 */
	private String validCode;

	public String getAuthOrderId() {
		return authOrderId;
	}

	public void setAuthOrderId(String authOrderId) {
		this.authOrderId = authOrderId;
	}

	public String getUserIp() {
		return userIp;
	}

	public void setUserIp(String userIp) {
		this.userIp = userIp;
	}

	public String getMerchantCode() {
		return merchantCode;
	}

	public void setMerchantCode(String merchantCode) {
		this.merchantCode = merchantCode;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public String getPaymentCode() {
		return paymentCode;
	}

	public void setPaymentCode(String paymentCode) {
		this.paymentCode = paymentCode;
	}

	public String getIdNo() {
		return idNo;
	}

	public void setIdNo(String idNo) {
		this.idNo = idNo;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getValidCode() {
		return validCode;
	}

	public void setValidCode(String validCode) {
		this.validCode = validCode;
	}

	@Override
	public boolean validate() throws Exception {
		if (StringUtils.isBlank(this.userIp)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'userIp'不能为空");
		}

		if (StringUtils.isBlank(this.authOrderId)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'authOrderId'不能为空");
		}

		if (StringUtils.isBlank(this.merchantCode)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'merchantCode'不能为空");
		}

		if (StringUtils.isBlank(this.orderId)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'orderId'不能为空");
		}

		if (StringUtils.isBlank(this.paymentCode)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'paymentCode'不能为空");
		}

		if (StringUtils.isBlank(this.idNo)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'idNo'不能为空");
		}

		if (StringUtils.isBlank(this.name)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'name'不能为空");
		}

		if (StringUtils.isBlank(this.cardNo)) {
			throw new YYException(RspCodeEnum.COMMON_ERROR_PARAMETER_INVALID, "参数 'cardNo'不能为空");
		}

		return true;
	}

	@Override
	public String[] signFields() {
		return new String[] { "userIp", "authOrderId", "merchantCode", "orderId", "paymentCode" };
	}

}
